package com.atcumt.Huawei;

import java.util.Scanner;

/**
 * 密码截取
 */
public class HJ6 {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int n = s.length();
        int maxLen = 0; // 最长密码串长度
        int index = 0;
        if (n < 2) {
            System.out.println(n);
        }

        boolean[][] dp = new boolean[n][n];
        for (int j = 1; j < n; j++) {
            for (int i = 0; i < j; i++) {
                if (s.charAt(i) != s.charAt(j)) {
                    continue;
                }

                if (j - i <= 2) {
                    dp[i][j] = true;
                } else {
                    dp[i][j] = dp[i + 1][j - 1];
                }

                // 如果字符串从i 到 j都是回文子串，只需要保存最长的即可
                if (dp[i][j] && j - i + 1 > maxLen) {
                    maxLen = j - i + 1;
                    index = i;
                }
            }
        }
        System.out.println(maxLen);
    }
}
